<?php

namespace Lib;


class Parser{
    
    /**
     *
     * @return \stdClass 
     */
    static function parseRequest(){
        $address = trim($_SERVER['REQUEST_URI']);
        $parseGet = explode('?', $address);
        $moduleParam = explode('/', $parseGet[0]);
        $result = new \stdClass;
        $result->module = $moduleParam;
        $result->get = array();
        if (isset($parseGet[1]) && !empty($parseGet[1])) {
            $temp = explode('&', $parseGet[1]);
            foreach ($temp as $v) {
                $temp1 = explode('=', $v);
                if(!empty($temp1[0])){
                    $result->get[$temp1[0]] = (isset($temp1[1])) ? $temp1[1] : '';
                }
            }
        }
        return $result;    
    }
}
?>
